<?php

// +----------------------------------------------------------------------
// | Chnxu
// +----------------------------------------------------------------------

declare (strict_types=1);

namespace app\databackup;

use app\databackup\command\DataBackup;
use think\admin\extend\CodeExtend;
use think\admin\Plugin;
use think\Request;

/**
 * 组件注册服务
 * @class Service
 * @package app\wechat
 */
class Service extends Plugin
{
    /**
     * 定义插件名称
     * @var string
     */
    protected $appName = '数据备份管理';

    /**
     * 定义安装包名
     * @var string
     */
    protected $package = 'chnxu/think-plugs-databackup';

    /**
     * 注册组件服务
     * @return void
     */
    public function register(): void
    {
        // 注册模块指令
        $this->commands([DataBackup::class]);
    }

    /**
     * 增加菜单
     * @return array[]
     */
    public static function menu(): array
    {
        $code = app(static::class)->appCode;
        // 设置插件菜单
        return [
            [
                'name' => '数据备份管理',
                'subs' => [
                    ['name' => '数据备份', 'icon' => 'layui-icon layui-icon-table', 'node' => "{$code}/databackup/index"],
                ],
            ],
        ];
    }
}